<template>
     <div class="box">
        
      <div class="warp">
          <h2>欢迎注册</h2>
         <input type="text" placeholder="请输入用户名" v-model="username">
         <input type="password" placeholder="密码" v-model="password">
          <input type="password" placeholder="确认密码" v-model="password1">
           <div class="guan">
               <el-radio v-model="radio" label="1">管理员注册</el-radio>
                <el-radio v-model="radio" label="0">店铺注册</el-radio>
            </div>
          
          <button @click="zhuce">注册</button>
         <h3 @click="denglu">返回登录页</h3>
      </div>
    </div>
</template>

<script>
import {ajax_register} from '../ajax/index'
export default {
    name: '',
    data(){
        return{
            username:'',
            password:'',
            password1:'',
            radio:'1',
        }
    },
    methods:{
       denglu(){
           this.$router.push("/")
       },
       zhuce(){
           if(this.password==this.password1){
               console.log(this.username);
                ajax_register({
                    username:this.username,
                    password:this.password,
                    radio:this.radio
                }).then(data=>{
                    alert(data.message)
                    this.$router.push("/");
                })
           }else{
               alert("两次密码不一致")
           }
          
       }
    },

}
</script>

<style scoped>
.box{
    width: 100vw;
    height: 100vh;
    background:url("../assets/zhucebei.jpg") no-repeat ;
    background-size: 100% 100%;
    text-align: center;
    position: relative;
    top: 0;
    z-index: 100;
}
.warp{
    width: 380px;
    height: 280px;
    background-color: white;
    border-radius: 8px;
    position: absolute;
    top: 0;
    left:0;
    right:0;
    bottom: 0;
    margin: auto;
}
h2{
    color:white;
    position: absolute;
    top:-70px;
    left: 120px;
}
h3{
    color: rgb(0, 17, 255);
    font-style: normal;
    font-size: 12px;
    text-decoration: underline;
    position: absolute;
    right:20px;
    bottom:7px;
}
input{
    width: 85%;
    margin: 0px auto;
    margin-top: 25px;
    border: none;
    outline: none;
    border: 1px solid gray;
    border-radius: 5px;
    padding: 8px 8px;
    background-color: #fffcc8;
}
button{
    outline: none;
    border: none;
    width: 90%;
    margin:15px auto;
    text-align: center;
    background-color: rgb(47, 255, 141);
    font-size: 18px;
    padding: 5px 0;
    color: white;
    border-radius: 5px;
}
p{
   position: absolute;
   right: 20px;
   bottom: 45px;
   color: blue;
   text-decoration: underline;
}
.guan{
    margin-top: 10px;
}
</style>